package com.thrift.distributed.web;

import com.alibaba.fastjson.JSONObject;
import com.thrift.distributed.annotation.ChargeManagement;
import com.thrift.distributed.vo.TestVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @包名称 com.thrift.distributed.web
 * @类描述 <pre></pre>
 * @作者 zhangbo
 * @创建时间 2019/9/20
 * @版本 1.00
 * @修改记录 <pre>
 *     版本           修改人         修改日期         修改内容描述
 *     -----------------------------------------------------------
 *     1.00           Lenovo        2019/9/20
 *     -----------------------------------------------------------
 * </pre>
 */
@Slf4j
@RestController
public class TestController {

    @PostMapping("/test")
    @ChargeManagement(methodName = "testMethod1",valueKeys = {"name","age"})
    public Object testMethod1(@RequestBody TestVo testVo) {
        log.info("test:" + JSONObject.toJSONString(testVo));
        if(testVo.isFlag()) {
            throw new RuntimeException("手动异常");
        }
        return "success";
    }

}
